<template>
  <V-CommonHeaderLeft>
    <div class="purchasing-order">
      <Navigation :msg="navMsg"></Navigation>
      <div class="purchasing-table">
        <el-table ref="multipleTable"
                  :data="stock"
                  style="width: 100%;"
                  :height="tableHeight"
                  class="table-class">
          <el-table-column type="selection"
                           min-width="4%">
          </el-table-column>
          <el-table-column prop="orderId"
                           label="采购单号"
                           min-width="10%"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.orderId">
                <div v-if="scope.row.orderOrder == '智'"
                     class="intelligence">{{ scope.row.orderOrder }}
                </div>{{ scope.row.orderId }}
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="from.name"
                           min-width="7.5%"
                           label="供应商">
            <template slot-scope="scope">
              <span :title="scope.row.from.name">{{ scope.row.from.name }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderAmount"
                           min-width="7.5%"
                           label="订单金额">
            <template slot-scope="scope">
              <span :title="scope.row.orderAmount">{{ scope.row.orderAmount }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="amountPaid"
                           min-width="7.5%"
                           label="已付金额">
            <template slot-scope="scope">
              <span :title="scope.row.amountPaid">{{ scope.row.amountPaid }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderStatus"
                           min-width="6%"
                           label="单据状态">
            <template slot-scope="scope">
              <span :class="(scope.row.orderStatus == '已完成' ? '' : 'not-status')">{{ scope.row.orderStatus }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="financialStatus"
                           min-width="6%"
                           label="财务状态">
            <template slot-scope="scope">
              <span :class="(scope.row.orderStatus == '已完成' ? '' : 'not-status')">{{ scope.row.orderStatus }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="afterStatus"
                           min-width="8%"
                           label="售后状态">
            <template slot-scope="scope">
              <span :class="(scope.row.orderStatus == '已完成' ? '' : 'not-status')">{{ scope.row.orderStatus }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="outEstimated"
                           min-width="10%"
                           label="送货日期">
            <template slot-scope="scope">
              <span :title="scope.row.outEstimated">{{ scope.row.outEstimated }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderPerson"
                           min-width="10%"
                           label="制单人">
            <template slot-scope="scope">
              <span :title="scope.row.orderPerson">{{ scope.row.orderPerson }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="submitTime"
                           min-width="10%"
                           label="提交时间"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.submitTime">{{ scope.row.submitTime }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="remarks"
                           min-width="7.5%"
                           label="订单备注">
            <template slot-scope="scope">
              <span :title="scope.row.remarks">{{ scope.row.remarks }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="remarks"
                           min-width="6%"
                           label="打印次数">
            <template slot-scope="scope">
              <span :title="scope.row.remarks">{{ scope.row.remarks }}</span>
            </template>
          </el-table-column>
        </el-table>
        <Paging :msg="pageMsg.length"
                ref="fn"
                @pageNum="getPageNum"
                @pageId="getPageId"></Paging>
      </div>
    </div>
  </V-CommonHeaderLeft>
</template>
<script>
import VCommonHeaderLeft from '@/components/common/vCommonHeaderLeft/VCommonHeaderLeft'
import Navigation from '@/components/common/navigation/Navigation'
import Paging from '@/components/common/paging/Paging'
export default {
  data () {
    return {
      tableHeight: '',
      pageNum: 15, // 每页默认显示15条,
      pageId: 1, // 页面id
      judgeStatus: false, // 排序状态
      navMsg: [
        {
          name: '采购',
          path: '/purchasingOrder'
        },
        {
          name: '采购订单',
          path: ''
        }
      ],
      stock: [],
      pageMsg: [
        {
          id: 1,
          orderId: 'CK-20190412-0003',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 2,
          orderOrder: '智',
          orderId: 'CK-20190423-0043',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 3,
          orderId: 'CK-20100422-023',
          from: {
            type: '供应商',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '待发货',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 4,
          orderId: 'CK-20200422-0563',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-21',
          submitTime: '2019-04-23',
          eemarks: ''
        },
        {
          id: 5,
          orderId: 'CK-21190422-0073',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '待提交',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-02-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 6,
          orderId: 'CK-20190422-0031',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-05-22',
          submitTime: '2019-05-22',
          eemarks: ''
        },
        {
          id: 7,
          orderId: 'CK-20190422-0603',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-23',
          submitTime: '2019-04-23',
          eemarks: ''
        },
        {
          id: 8,
          orderId: 'CK-20190422-0803',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 9,
          orderId: 'CK-20190422-1115',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 10,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 11,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 12,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 13,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 14,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '待发货',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        }
      ]
    }
  },
  components: {
    Navigation,
    Paging,
    VCommonHeaderLeft
  },
  created () {
    this.stock = this.pageMsg
    this.getHight()
    window.addEventListener('resize', this.getHight)
  },
  destroyed () {
    window.removeEventListener('resize', this.getHight)
  },
  methods: {
    getHight () {
      this.tableHeight = window.innerHeight - 162 + 'px'
    },
    getPageId (id = 1) {
      this.pageId = id
      this.stock = this.$refs.fn.sliceArray(this.pageMsg, this.pageNum, id - 1)
    },
    getPageNum (num) {
      this.pageNum = num
      this.getPageId()
    }
  }
}
</script>
<style lang="scss" scoped>
.purchasing-order {
  width: 100%;
  margin-right: 10px;
  overflow: hidden;
  background-color: #ffffff;
  .purchasing-table {
    width: 100%;
    @mixin el-common($el-color, $el-height, $el-class) {
      padding: 0;
      color: $el-color;
      height: $el-height;
      line-height: $el-height;
      &:first-child {
        text-align: center;
        span {
          width: 16px;
          height: 16px;
        }
      }
      &:not(:first-child) {
        #{$el-class} {
          width: 100%;
          line-height: 20px;
          display: -webkit-box;
          overflow: hidden;
          white-space: normal !important;
          text-overflow: ellipsis;
          word-wrap: break-word;
          word-break: break-all;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }
    }
    /deep/ .el-table__body-wrapper {
      overflow-x: hidden;
      overflow-y: hidden;
      &:hover {
        overflow-y: overlay;
      }
      &::-webkit-scrollbar {
        width: 8px;
        height: 50%;
      }
      &::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background-color: rgba(0, 0, 0, 0.2);
      }
      &::-webkit-scrollbar-track {
        border-radius: 0;
        background-color: rgba(0, 0, 0, 0.1);
      }
    }
    /deep/ .table-class {
      font-size: 12px;
      padding: 0;
      tr {
        td {
          @include el-common(
            $el-color: #333,
            $el-height: 40px,
            $el-class: "span"
          );
          &:nth-child(2) {
            &:hover {
              cursor: pointer;
              color: #20bdeb;
            }
          }
          .intelligence {
            width: 18px;
            color: #fff;
            background-color: #7dcdf3;
            display: inline-block;
            vertical-align: middle;
            padding: 0 3px;
            text-align: center;
            line-height: 18px;
            margin-right: 6px;
            border-radius: 2px;
          }
        }
        th {
          @include el-common(
            $el-color: #666,
            $el-height: 50px,
            $el-class: ".cell"
          );
          font-weight: normal;
          background-color: #fcfcfc;
        }
      }
      .order-from {
        color: #65d142;
      }
      .not-status {
        color: #ff3838;
      }
    }
  }
}
</style>
